<?php 
require_once ('nav.php');
   $id = $_GET['id'];  
   $sql = "select * from users where uid={$id}";   
   $result = mysql_query($sql) or die('查询失败edit！'.mysql_error());   
   $row = mysql_fetch_assoc($result);
   //$row = fetch_one($sql);相当于5、6行
   //var_dump($row);   
   $uname = $row['uname'];
   $password = $row['password'];
   $gender = $row['gender'];
   $birthdate = $row['birthdate'];
   $hobby = $row['hobby'];
   $degree = $row['degree'];
   $intro = $row['intro'];
   $pic = UserPhotoPath.$row['pic'];  
 ?>
 <div class="col-sm-9 col-md-10">
  <h2  align="center">用户编辑</h2>

   <form method="post" action="userUpdate.php"  enctype="multipart/form-data" class="form-horizontal">
   <input type="hidden" name="id" value="<?php echo $id; ?>" >

    <div class="form-group">
      <label for="uname" class="col-md-2 col-xs-3 control-label">用户名</label>
        <div class="col-md-10  col-xs-9">
        <input type="text" class="form-control" name="uname" 
        placeholder="用户名" name="uname" value="<?php echo $uname ;?>" >
        </div>
    </div>

     <div class="form-group">
      <label for="password" class="col-md-2 col-xs-3 control-label">密码</label>
        <div class="col-md-10  col-xs-9">
        <input type="text" class="form-control" name="password" 
        placeholder="用户名" value="<?php echo $password ;?>" >
        </div>
    </div>

    <div class="form-group">
     <label class="col-md-2 col-xs-3 control-label" for="gender">性别</label>
      <div class="col-md-10 col-xs-9">
        <label class="radio-inline">
        <input name="gender" type="radio" value="0" id="gender" 
        <?php
          //echo $gender==0?'checked':'';
          if($gender==0){echo 'checked';} else echo ''; ?>>男
        </label>
        <label class="radio-inline">
        <input name="gender" type="radio" value="0" id="gender"
        <?php
          //echo $gender==0?'checked':'';
          if($gender==2){echo 'checked';} else echo ''; ?>>女
        </label>
      </div>
    </div>

    <div class="form-group">
      <label class="col-md-2 col-xs-3 control-label" for="birthdate">出生日期</label>
      <div class="col-md-10 col-xs-9">
      <input type="data" class="form-control" name="birthdate" value=<?php echo $birthdate ?> >
      </div>
    </div>




    <div class="form-group">
    <label class="col-md-2 col-xs-3 control-label"  for="hobby">爱好</label>
      <div class="col-md-10 col-xs-9">
          <label class="radio-inline">
            <input type="checkbox" name="hobby[]" id="hobby" value="游泳"
            <?php if(strstr($hobby,'游泳')){echo 'checked';}?>> 游泳
          </label> 

          <label class="radio-inline">
            <input type="checkbox" name="hobby[]" id="hobby" value="登山"
            <?php if(strstr($hobby,'登山')){echo 'checked';}?>> 登山
          </label>   

          <label class="radio-inline">
            <input type="checkbox" name="hobby[]" id="hobby" value="健身"
            <?php if(strstr($hobby,'健身')){echo 'checked';}?> > 健身
          </label> 
      </div>
    </div>
 

  <div class="form-group">
      <label class="col-md-2 col-xs-3 control-label"  for="degree" >学历</label>
      <div class="col-md-10 col-xs-9">
        <select class="form-control" name="degree">
        <option value="1">高中</option>
        <option value="2">大学</option>
        <option value="3">研究生</option>
        <option value="4">博士生</option>
        <option value="0">不知道</option>
      </select>
      </div>
  </div>


  <div class="form-group">
    <label class="col-md-2 col-xs-3 control-label" for="intro">个人简介</label>
    <div class="col-md-10 col-xs-9">
    <input type="text" class="form-control" name="intro"  value=<?php echo $intro ?> >
    </div>
  </div>

  <div class="form-group">
    <label class="col-md-2 col-xs-3 control-label" for="pic">头像</label>
    <div class="col-md-10 col-xs-9">
    <input type="file" class="form-control" name="pic"  value=<?php echo $pic ?> >
    </div>
  </div>

  <div class="form-group">
     <label class="col-xs-3"></label>
     <div class="col-md-10 col-md-offset-2" ><!--offset向右偏移两个格-->
     <input type="submit" value="修改">
     <input type="reset" value="重置">
     </div>
  </div>
 
 
   </input>
   </form>
 </div>


 <?php 
require_once ('footer.php');
  ?>